<%@ page language="java" import="org.json.*,java.sql.*,com.microsoft.sqlserver.jdbc.*,java.io.*,web.rec.*" 
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"  %>

<% 
	Connection conn = ResourceTool.getConnection();
	String degree_name = request.getParameter("degree_name");
	try {
	// Create the prepared statement and use it to
	// INSERT the student attrs INTO the Student table.
	Statement stmt = conn.createStatement();
	ResultSet rs = stmt.executeQuery("SELECT * from degree where degree_name = '" + degree_name +"'");
	if ( rs.next()) { // found send JSON string with employee details to client
	    out.println("{\"type\":");
	    out.println("\"" + rs.getString("type") + "\"");
	    out.println(",\"unit\":");
	    out.println("\"" + rs.getInt("unit") + "\"");
	    out.println("}");
	 }
	 else {  // not found send JSON string with error message
	     out.println("{\"error\":\"degree name not found!\"}");
	 }
	// Close the ResultSet
	rs.close();
	// Close the Statement
	stmt.close();
	} catch (SQLException sqle) {
		out.println(sqle.getMessage());
	} catch (Exception e) {
		out.println(e.getMessage());
	}
	%>